#!/usr/bin/python
# -*- coding: utf-8 -*-

from bottle import Bottle
from bottle import debug, run
from bottle import redirect, abort, static_file
from bottle import jinja2_template as template
from bottle import request, response, local
from bottle import TEMPLATE_PATH

from setting import CUSTOM_TPL_PATH, STATIC_FILE_PATH

from models import Entry

import entry, ajax, admin

TEMPLATE_PATH.insert(0, CUSTOM_TPL_PATH)

app = Bottle()

app.mount('/entry', entry.app)
app.mount('/ajax', ajax.app)
app.mount('/admin', admin.app)

@app.route('/static/<filepath:path>')
def handle_static(filepath):
    return static_file(filepath, root=STATIC_FILE_PATH)

@app.route('/about')
def handle_about():
    return template('about')

@app.route('/')
def handle_index():
    return entry.handle_list_recent()

if __name__ == '__main__':
    debug(True)
    run(app, host="0.0.0.0",reloader=True)
